package com.careercup.question.id18120664;

public class Solution {
	private static int charToDigit(char c) {
		return c - '0';
	}
	private static String add(String n1, String n2) {
		char[] cn1 = n1.toCharArray(), cn2 = n2.toCharArray(), cn3 = new char[Math.max(cn1.length, cn2.length) + 1];
		int c = 0;
		for(int i = 0; i < cn3.length; i++) {
			int cn1i = cn1.length - i - 1, cn2i = cn2.length - i - 1;
			int s = (cn1i >= 0 ? charToDigit(cn1[cn1i]) : 0) + (cn2i >= 0 ? charToDigit(cn2[cn2i]) : 0) + c;
			cn3[cn3.length - i - 1] = Character.forDigit(s % 10, 10);
			c = s / 10;
		}
		String sum = "";
		int i = cn3[0] > '0' ? 0 : 1;
		for(; i < cn3.length; i++)
			sum += cn3[i];
		return sum;
	}
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		System.out.println(add("12345", "99321"));
	}
}
